import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class SierpinskiCurveTurtle here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class SierpinskiCurveTurtle extends Turtle
{
    /**
     * Act - do whatever the SierpinskiCurveTurtle wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // Add your action code here.
    }    
    public SierpinskiCurveTurtle(){
        penDown();
        
    }
    public void drawSierpinskiCurve(int n, double len){
        if(n == 0)
            move(len);
        else{
            B(n-1, len);
            turn(-60);
            drawSierpinskiCurve(n-1, len);
            turn(-60);
            B(n-1, len);
        }
    }
    void B(int n, double len){
        if(n == 0)
            move(len);
        else{
            drawSierpinskiCurve(n-1, len);
            turn(60);
            B(n-1, len);
            turn(60);
            drawSierpinskiCurve(n-1, len);
        }
    }
}
